﻿using System.Windows;
using Me.Amon.C;

namespace Me.Amon.Open.UI
{
    /// <summary>
    /// Auth.xaml 的交互逻辑
    /// </summary>
    public partial class Auth : Window
    {
        #region 构造函数
        public Auth()
        {
            InitializeComponent();
        }

        public Auth(string uri)
        {
            InitializeComponent();

            WbAuth.Navigate(uri);
        }
        #endregion

        public AmonHandler<string> CallBack { get; set; }

        public string Token { get; private set; }

        #region 事件处理
        private void BnOk_Click(object sender, RoutedEventArgs e)
        {
            Token = (TbCode.Text ?? "").Trim();
            if (string.IsNullOrEmpty(TbCode.Text))
            {
                MessageBox.Show("请输入代码！");
                TbCode.Focus();
                return;
            }
            if (CallBack != null)
            {
                CallBack(Token);
            }
            DialogResult = true;
            Close();
        }

        private void BnNo_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
            Close();
        }
        #endregion
    }
}
